<?php

/*
 * Action
 * 
 * 3$
 * 
 * +1 card, +1 action, +1$, discard a card
 * 
 */

class Oasis extends Card implements iAction, iKingdom {

    public function __construct() {
        parent::__construct("Oasis", 3);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "+1 Card",
            "+1 Action",
            "+$1",
            "Discard a card.");
    }

    public function play(Game $game, $isRealCard) {
        $game->addActions(1);
        $game->addMoney(new Price(1));
        $drawed_cards = $game->drawCards(1);
        ScreenDisplay::addScreenMessage($game, true, "get +1 action, +1$ and draw " . nicePrint($drawed_cards), "gets +1 action, +1$ and draws " . sizeof($drawed_cards) . " cards");

        $playHand = $game->getPlayHand();
        if (sizeof($playHand) > 0) {
            $playHand = getUniqueCards($playHand);
            $card = null;
            if (sizeof($playHand) > 1) {
                $output = MySocket::GetUserReply($game, Input_ChooseOne, $playHand, 1, 1, null, "Choose card to discard");
                $card = n2c($output[0]);
            } else {
                $card = $playHand[0];
            }
            $card = $game->moveCardFromPileToPile($card, PlayHand, DiscardPile);
            ScreenDisplay::addScreenMessage($game, true, "discard " . nicePrint($card), "discards " . sizeof($card) . " cards");
        }
        
        $game->cardActionFinished();
        return true;
    }

}
